package com.cjm.one.system.client;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.common.constant.SecurityConstants;
import com.cjm.one.common.constant.ServerConstants;
import com.cjm.one.common.result.Result;
import com.cjm.one.model.base.PasswordDto;
import com.cjm.one.model.base.TokenVo;
import com.cjm.one.model.auth.system.dto.LoginDto;
import com.cjm.one.model.auth.system.vo.CaptchaCodeVo;
import com.cjm.one.model.system.dto.SysUserInfoDto;
import com.cjm.one.model.system.dto.SysUserInfoFromDto;
import com.cjm.one.model.system.entity.SysResource;
import com.cjm.one.model.system.entity.SysRole;
import com.cjm.one.model.system.entity.SysUserInfo;
import com.cjm.one.model.system.entity.SysUserRole;
import com.cjm.one.model.system.vo.SysResourceVo;
import com.cjm.one.model.system.vo.SysUserInfoVo;
import io.swagger.v3.oas.annotations.Operation;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.cloud.openfeign.FeignClient;

import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = ServerConstants.SERVER_ONE_SYSTEM)
public interface SyStemUserClient {
    /**
     * @description:管理系统登录
     * @author: cjm
     * @date: 2024/9/8 20:05
     * @param: [LoginDto, captchaCodeDto]
     * @return: com.one.common.core.result.Result<java.lang.String>
     **/
    @PostMapping("/admin/auth/system/login")
    Result<TokenVo> login(@Validated @RequestBody LoginDto LoginDto);

    /**
     * @description:后台登录获取验证码
     * @author: cjm
     * @date: 2024/9/8 20:07
     * @param: []
     * @return: com.one.common.core.result.Result<com.one.model.auth.system.vo.CaptchaCodeVo>
     **/
    @GetMapping("/admin/auth/system/captchaCode")
    Result<CaptchaCodeVo> getCaptchaCode();
    @GetMapping("/admin/auth/system/userInfo")
    @Operation(summary = "获取当前登录用户信息")
    Result<SysUserInfo> userInfo(@RequestHeader("Authorization") String Authorization);
    @GetMapping("/admin/auth/system/menuTree")
    @Operation(summary = "获取当前登录用户的菜单树")
    Result<List<SysResourceVo>> getAllMenuList();
    /**
     * @description:根据用户名查询用户信息
     * @author: cjm 
     * @date: 2024/9/20 20:50
     * @param: [username]
     * @return: com.cjm.one.common.result.Result<com.cjm.one.model.system.entity.SysUserInfo>
     **/
    @GetMapping("/admin/system/sysUser/name/{username}")
    Result<SysUserInfo> getUserByName(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String fromSource);

    /**
     * @description:根据用户id查询用户权限
     * @author: cjm
     * @date: 2024/9/20 20:50
     * @param: [userId]
     * @return: com.cjm.one.common.result.Result<java.util.List<java.lang.String>>
     **/
    @PostMapping("/admin/auth/system/findUserPermsList/{userId}")
    Result<List<String>> findUserPermsList(@PathVariable("userId") Long userId,@RequestHeader(SecurityConstants.FROM_SOURCE) String fromSource);
    /**
     * @description: 新增用户
     * @author: cjm 
     * @date: 2024/9/20 20:50
     * @param: [sysUserInfo]
     * @return: com.cjm.one.common.result.Result<java.lang.Boolean>
     **/
    @PostMapping("/admin/system/sysUser")
    Result<Boolean> saveUser(@RequestBody SysUserInfo sysUserInfo);
    /**
     * @description: 根据id查询用户信息
     * @author: cjm
     * @date: 2024/9/30 21:10
     * @param: [id]
     * @return: com.cjm.one.common.result.Result<com.cjm.one.model.system.vo.LoginVo>
     **/
    @GetMapping("/admin/system/sysUser/{id}")
    Result<SysUserInfoVo> getUserInfoById(@PathVariable("id") Long id);

    /**
     * @description: 根据id删除系统用户
     * @author: cjm 
     * @date: 2024/10/2 22:36
     * @param: [id]
     * @return: com.cjm.one.common.result.Result<java.lang.Boolean>
     **/
    @DeleteMapping("/admin/system/sysUser/{id}")
     Result<Boolean> deleteSysUser(@PathVariable("id") Long id) ;

    /**
     * @description: 根据id修改系统用户
     * @author: cjm 
     * @date: 2024/10/3 9:58
     * @param: [sysUserInfoDto]
     * @return: com.cjm.one.common.result.Result<java.lang.Boolean>
     **/
    @PutMapping("/admin/system/sysUser")
    Result<Boolean> updateSysUser(@RequestBody SysUserInfoDto sysUserInfoDto) ;
    /**
     * @description: 修改系统用户密码
     * @author: cjm 
     * @date: 2024/10/4 10:08
     * @param: [passwordDto]
     * @return: com.cjm.one.common.result.Result<java.lang.Boolean>
     **/
    @PutMapping("/admin/system/sysUser/password")
     Result<Boolean> updateSysUserPassword(@RequestBody PasswordDto passwordDto);
    /**
     * @description: 修改系统用户状态
     * @author: cjm 
     * @date: 2024/10/4 10:40
     * @param: [sysUserInfoDto]
     * @return: com.cjm.one.common.result.Result<java.lang.Boolean>
     **/
    @PutMapping("/admin/system/sysUser/status")
     Result<Boolean> updateSysUserStatus(@RequestBody SysUserInfoDto sysUserInfoDto);
    /**
     * @description: 根据用户id获取角色list
     * @author: cjm
     * @date: 2024/10/4 10:41
     * @param: [userId]
     * @return: com.cjm.one.common.result.Result<java.util.List<com.cjm.one.model.system.entity.SysUserRole>>
     **/
    @GetMapping("/admin/system/sysUser/roleByUserId/{userId}")
     Result<List<SysUserRole>> getSysUserRoleByIdList(@PathVariable("userId") Long userId) ;
    /**
     * @description: 分页条件查询列表
     * @author: cjm
     * @date: 2024/10/8 10:01
     * @param: [queryVo]
     * @return: com.cjm.one.common.result.Result<com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.cjm.one.model.system.vo.SysUserInfoVo>>
     **/
    @PostMapping("/admin/system/sysUser/page")
     Result<Page<SysUserInfoVo>> getSysUserPage(@RequestBody SysUserInfoFromDto queryVo);
    /**
     * @description: 批量删除用户
     * @author: cjm 
     * @date: 2024/10/8 13:29
     * @param: [ids]
     * @return: com.cjm.one.common.result.Result<java.lang.Integer> 成功的条数
     **/
    @DeleteMapping("/admin/system/sysUser/deleteMore")
     Result<Integer> deleteSysUserMore( @RequestBody List<Long> ids);
    /**
     * @description: 重置密码
     * @author: cjm
     * @date: 2024/10/8 13:55
     * @param: [id]
     * @return: com.cjm.one.common.result.Result<java.lang.Boolean>
     **/
    @PutMapping("/admin/system/sysUser/resetPassword")
     Result<Boolean> resetPassword(@RequestBody PasswordDto passwordDto);

}
